// Copyright (c) 2024, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// With JS, bitwise operators operate on a 32-bit unsigned value, but the
// semantics is shared with native platforms as indicated in `test` and
// `testUnary` below: With uint32 input and `toUnsigned(32)` on the expected
// value, the results coincide. Note that this test contains the same test
// cases as `bitops_unsigned_js_test.dart`, except the ones where at least
// one operand is outside the set of values that are representable as a
// 32-bit unsigned value.
//
// Bitwise operators: &, |, ^, ~, <<, >>, >>>.

import 'package:expect/expect.dart';
import 'package:expect/variations.dart';

int bitAnd(int a, int b) => a & b;
int bitOr(int a, int b) => a | b;
int bitXor(int a, int b) => a ^ b;
int bitShiftLeft(int a, int b) => a << b;
int bitShiftRight(int a, int b) => a >> b;
int bitShiftRightLogical(int a, int b) => a >>> b;
int bitInvert(int a) => ~a;

void test(int expected, int Function(int, int) fn, int a, int b) {
  int value = fn(a, b);
  if (jsNumbers) {
    Expect.equals(expected, value);
  } else {
    Expect.equals(expected, value.toUnsigned(32));
  }
}

void testUnary(int expected, int Function(int) fn, int a) {
  int value = fn(a);
  if (jsNumbers) {
    Expect.equals(expected, value);
  } else {
    Expect.equals(expected, value.toUnsigned(32));
  }
}

void main() {
  test(0x0, bitAnd, 0x0, 0x0);
  test(0x0, bitAnd, 0x0, 0x1);
  test(0x0, bitAnd, 0x0, 0x2);
  test(0x0, bitAnd, 0x0, 0xa);
  test(0x0, bitAnd, 0x0, 0xbd217d);
  test(0x0, bitAnd, 0x0, 0xfedcba98);
  test(0x0, bitAnd, 0x0, 0xfffffffe);
  test(0x0, bitAnd, 0x0, 0xffffffff);
  test(0x0, bitAnd, 0x1, 0x0);
  test(0x1, bitAnd, 0x1, 0x1);
  test(0x0, bitAnd, 0x1, 0x2);
  test(0x0, bitAnd, 0x1, 0xa);
  test(0x1, bitAnd, 0x1, 0xbd217d);
  test(0x0, bitAnd, 0x1, 0xfedcba98);
  test(0x0, bitAnd, 0x1, 0xfffffffe);
  test(0x1, bitAnd, 0x1, 0xffffffff);
  test(0x0, bitAnd, 0x2, 0x0);
  test(0x0, bitAnd, 0x2, 0x1);
  test(0x2, bitAnd, 0x2, 0x2);
  test(0x2, bitAnd, 0x2, 0xa);
  test(0x0, bitAnd, 0x2, 0xbd217d);
  test(0x0, bitAnd, 0x2, 0xfedcba98);
  test(0x2, bitAnd, 0x2, 0xfffffffe);
  test(0x2, bitAnd, 0x2, 0xffffffff);
  test(0x0, bitAnd, 0xa, 0x0);
  test(0x0, bitAnd, 0xa, 0x1);
  test(0x2, bitAnd, 0xa, 0x2);
  test(0xa, bitAnd, 0xa, 0xa);
  test(0x8, bitAnd, 0xa, 0xbd217d);
  test(0x8, bitAnd, 0xa, 0xfedcba98);
  test(0xa, bitAnd, 0xa, 0xfffffffe);
  test(0xa, bitAnd, 0xa, 0xffffffff);
  test(0x0, bitAnd, 0xbd217d, 0x0);
  test(0x1, bitAnd, 0xbd217d, 0x1);
  test(0x0, bitAnd, 0xbd217d, 0x2);
  test(0x8, bitAnd, 0xbd217d, 0xa);
  test(0xbd217d, bitAnd, 0xbd217d, 0xbd217d);
  test(0x9c2018, bitAnd, 0xbd217d, 0xfedcba98);
  test(0xbd217c, bitAnd, 0xbd217d, 0xfffffffe);
  test(0xbd217d, bitAnd, 0xbd217d, 0xffffffff);
  test(0x0, bitAnd, 0xfedcba98, 0x0);
  test(0x0, bitAnd, 0xfedcba98, 0x1);
  test(0x0, bitAnd, 0xfedcba98, 0x2);
  test(0x8, bitAnd, 0xfedcba98, 0xa);
  test(0x9c2018, bitAnd, 0xfedcba98, 0xbd217d);
  test(0xfedcba98, bitAnd, 0xfedcba98, 0xfedcba98);
  test(0xfedcba98, bitAnd, 0xfedcba98, 0xfffffffe);
  test(0xfedcba98, bitAnd, 0xfedcba98, 0xffffffff);
  test(0x0, bitAnd, 0xfffffffe, 0x0);
  test(0x0, bitAnd, 0xfffffffe, 0x1);
  test(0x2, bitAnd, 0xfffffffe, 0x2);
  test(0xa, bitAnd, 0xfffffffe, 0xa);
  test(0xbd217c, bitAnd, 0xfffffffe, 0xbd217d);
  test(0xfedcba98, bitAnd, 0xfffffffe, 0xfedcba98);
  test(0xfffffffe, bitAnd, 0xfffffffe, 0xfffffffe);
  test(0xfffffffe, bitAnd, 0xfffffffe, 0xffffffff);
  test(0x0, bitAnd, 0xffffffff, 0x0);
  test(0x1, bitAnd, 0xffffffff, 0x1);
  test(0x2, bitAnd, 0xffffffff, 0x2);
  test(0xa, bitAnd, 0xffffffff, 0xa);
  test(0xbd217d, bitAnd, 0xffffffff, 0xbd217d);
  test(0xfedcba98, bitAnd, 0xffffffff, 0xfedcba98);
  test(0xfffffffe, bitAnd, 0xffffffff, 0xfffffffe);
  test(0xffffffff, bitAnd, 0xffffffff, 0xffffffff);

  test(0x0, bitOr, 0x0, 0x0);
  test(0x1, bitOr, 0x0, 0x1);
  test(0x2, bitOr, 0x0, 0x2);
  test(0xa, bitOr, 0x0, 0xa);
  test(0xbd217d, bitOr, 0x0, 0xbd217d);
  test(0xfedcba98, bitOr, 0x0, 0xfedcba98);
  test(0xfffffffe, bitOr, 0x0, 0xfffffffe);
  test(0xffffffff, bitOr, 0x0, 0xffffffff);
  test(0x1, bitOr, 0x1, 0x0);
  test(0x1, bitOr, 0x1, 0x1);
  test(0x3, bitOr, 0x1, 0x2);
  test(0xb, bitOr, 0x1, 0xa);
  test(0xbd217d, bitOr, 0x1, 0xbd217d);
  test(0xfedcba99, bitOr, 0x1, 0xfedcba98);
  test(0xffffffff, bitOr, 0x1, 0xfffffffe);
  test(0xffffffff, bitOr, 0x1, 0xffffffff);
  test(0x2, bitOr, 0x2, 0x0);
  test(0x3, bitOr, 0x2, 0x1);
  test(0x2, bitOr, 0x2, 0x2);
  test(0xa, bitOr, 0x2, 0xa);
  test(0xbd217f, bitOr, 0x2, 0xbd217d);
  test(0xfedcba9a, bitOr, 0x2, 0xfedcba98);
  test(0xfffffffe, bitOr, 0x2, 0xfffffffe);
  test(0xffffffff, bitOr, 0x2, 0xffffffff);
  test(0xa, bitOr, 0xa, 0x0);
  test(0xb, bitOr, 0xa, 0x1);
  test(0xa, bitOr, 0xa, 0x2);
  test(0xa, bitOr, 0xa, 0xa);
  test(0xbd217f, bitOr, 0xa, 0xbd217d);
  test(0xfedcba9a, bitOr, 0xa, 0xfedcba98);
  test(0xfffffffe, bitOr, 0xa, 0xfffffffe);
  test(0xffffffff, bitOr, 0xa, 0xffffffff);
  test(0xbd217d, bitOr, 0xbd217d, 0x0);
  test(0xbd217d, bitOr, 0xbd217d, 0x1);
  test(0xbd217f, bitOr, 0xbd217d, 0x2);
  test(0xbd217f, bitOr, 0xbd217d, 0xa);
  test(0xbd217d, bitOr, 0xbd217d, 0xbd217d);
  test(0xfefdbbfd, bitOr, 0xbd217d, 0xfedcba98);
  test(0xffffffff, bitOr, 0xbd217d, 0xfffffffe);
  test(0xffffffff, bitOr, 0xbd217d, 0xffffffff);
  test(0xfedcba98, bitOr, 0xfedcba98, 0x0);
  test(0xfedcba99, bitOr, 0xfedcba98, 0x1);
  test(0xfedcba9a, bitOr, 0xfedcba98, 0x2);
  test(0xfedcba9a, bitOr, 0xfedcba98, 0xa);
  test(0xfefdbbfd, bitOr, 0xfedcba98, 0xbd217d);
  test(0xfedcba98, bitOr, 0xfedcba98, 0xfedcba98);
  test(0xfffffffe, bitOr, 0xfedcba98, 0xfffffffe);
  test(0xffffffff, bitOr, 0xfedcba98, 0xffffffff);
  test(0xfffffffe, bitOr, 0xfffffffe, 0x0);
  test(0xffffffff, bitOr, 0xfffffffe, 0x1);
  test(0xfffffffe, bitOr, 0xfffffffe, 0x2);
  test(0xfffffffe, bitOr, 0xfffffffe, 0xa);
  test(0xffffffff, bitOr, 0xfffffffe, 0xbd217d);
  test(0xfffffffe, bitOr, 0xfffffffe, 0xfedcba98);
  test(0xfffffffe, bitOr, 0xfffffffe, 0xfffffffe);
  test(0xffffffff, bitOr, 0xfffffffe, 0xffffffff);
  test(0xffffffff, bitOr, 0xffffffff, 0x0);
  test(0xffffffff, bitOr, 0xffffffff, 0x1);
  test(0xffffffff, bitOr, 0xffffffff, 0x2);
  test(0xffffffff, bitOr, 0xffffffff, 0xa);
  test(0xffffffff, bitOr, 0xffffffff, 0xbd217d);
  test(0xffffffff, bitOr, 0xffffffff, 0xfedcba98);
  test(0xffffffff, bitOr, 0xffffffff, 0xfffffffe);
  test(0xffffffff, bitOr, 0xffffffff, 0xffffffff);

  test(0x0, bitXor, 0x0, 0x0);
  test(0x1, bitXor, 0x0, 0x1);
  test(0x2, bitXor, 0x0, 0x2);
  test(0xa, bitXor, 0x0, 0xa);
  test(0xbd217d, bitXor, 0x0, 0xbd217d);
  test(0xfedcba98, bitXor, 0x0, 0xfedcba98);
  test(0xfffffffe, bitXor, 0x0, 0xfffffffe);
  test(0xffffffff, bitXor, 0x0, 0xffffffff);
  test(0x1, bitXor, 0x1, 0x0);
  test(0x0, bitXor, 0x1, 0x1);
  test(0x3, bitXor, 0x1, 0x2);
  test(0xb, bitXor, 0x1, 0xa);
  test(0xbd217c, bitXor, 0x1, 0xbd217d);
  test(0xfedcba99, bitXor, 0x1, 0xfedcba98);
  test(0xffffffff, bitXor, 0x1, 0xfffffffe);
  test(0xfffffffe, bitXor, 0x1, 0xffffffff);
  test(0x2, bitXor, 0x2, 0x0);
  test(0x3, bitXor, 0x2, 0x1);
  test(0x0, bitXor, 0x2, 0x2);
  test(0x8, bitXor, 0x2, 0xa);
  test(0xbd217f, bitXor, 0x2, 0xbd217d);
  test(0xfedcba9a, bitXor, 0x2, 0xfedcba98);
  test(0xfffffffc, bitXor, 0x2, 0xfffffffe);
  test(0xfffffffd, bitXor, 0x2, 0xffffffff);
  test(0xa, bitXor, 0xa, 0x0);
  test(0xb, bitXor, 0xa, 0x1);
  test(0x8, bitXor, 0xa, 0x2);
  test(0x0, bitXor, 0xa, 0xa);
  test(0xbd2177, bitXor, 0xa, 0xbd217d);
  test(0xfedcba92, bitXor, 0xa, 0xfedcba98);
  test(0xfffffff4, bitXor, 0xa, 0xfffffffe);
  test(0xfffffff5, bitXor, 0xa, 0xffffffff);
  test(0xbd217d, bitXor, 0xbd217d, 0x0);
  test(0xbd217c, bitXor, 0xbd217d, 0x1);
  test(0xbd217f, bitXor, 0xbd217d, 0x2);
  test(0xbd2177, bitXor, 0xbd217d, 0xa);
  test(0x0, bitXor, 0xbd217d, 0xbd217d);
  test(0xfe619be5, bitXor, 0xbd217d, 0xfedcba98);
  test(0xff42de83, bitXor, 0xbd217d, 0xfffffffe);
  test(0xff42de82, bitXor, 0xbd217d, 0xffffffff);
  test(0xfedcba98, bitXor, 0xfedcba98, 0x0);
  test(0xfedcba99, bitXor, 0xfedcba98, 0x1);
  test(0xfedcba9a, bitXor, 0xfedcba98, 0x2);
  test(0xfedcba92, bitXor, 0xfedcba98, 0xa);
  test(0xfe619be5, bitXor, 0xfedcba98, 0xbd217d);
  test(0x0, bitXor, 0xfedcba98, 0xfedcba98);
  test(0x1234566, bitXor, 0xfedcba98, 0xfffffffe);
  test(0x1234567, bitXor, 0xfedcba98, 0xffffffff);
  test(0xfffffffe, bitXor, 0xfffffffe, 0x0);
  test(0xffffffff, bitXor, 0xfffffffe, 0x1);
  test(0xfffffffc, bitXor, 0xfffffffe, 0x2);
  test(0xfffffff4, bitXor, 0xfffffffe, 0xa);
  test(0xff42de83, bitXor, 0xfffffffe, 0xbd217d);
  test(0x1234566, bitXor, 0xfffffffe, 0xfedcba98);
  test(0x0, bitXor, 0xfffffffe, 0xfffffffe);
  test(0x1, bitXor, 0xfffffffe, 0xffffffff);
  test(0xffffffff, bitXor, 0xffffffff, 0x0);
  test(0xfffffffe, bitXor, 0xffffffff, 0x1);
  test(0xfffffffd, bitXor, 0xffffffff, 0x2);
  test(0xfffffff5, bitXor, 0xffffffff, 0xa);
  test(0xff42de82, bitXor, 0xffffffff, 0xbd217d);
  test(0x1234567, bitXor, 0xffffffff, 0xfedcba98);
  test(0x1, bitXor, 0xffffffff, 0xfffffffe);
  test(0x0, bitXor, 0xffffffff, 0xffffffff);

  test(0x0, bitShiftLeft, 0x0, 0x0);
  test(0x0, bitShiftLeft, 0x0, 0x1);
  test(0x0, bitShiftLeft, 0x0, 0x2);
  test(0x0, bitShiftLeft, 0x0, 0xa);
  test(0x0, bitShiftLeft, 0x0, 0xbd217d);
  test(0x0, bitShiftLeft, 0x0, 0xfedcba98);
  test(0x0, bitShiftLeft, 0x0, 0xfffffffe);
  test(0x0, bitShiftLeft, 0x0, 0xffffffff);
  test(0x1, bitShiftLeft, 0x1, 0x0);
  test(0x2, bitShiftLeft, 0x1, 0x1);
  test(0x4, bitShiftLeft, 0x1, 0x2);
  test(0x400, bitShiftLeft, 0x1, 0xa);
  test(0x0, bitShiftLeft, 0x1, 0xbd217d);
  test(0x0, bitShiftLeft, 0x1, 0xfedcba98);
  test(0x0, bitShiftLeft, 0x1, 0xfffffffe);
  test(0x0, bitShiftLeft, 0x1, 0xffffffff);
  test(0x2, bitShiftLeft, 0x2, 0x0);
  test(0x4, bitShiftLeft, 0x2, 0x1);
  test(0x8, bitShiftLeft, 0x2, 0x2);
  test(0x800, bitShiftLeft, 0x2, 0xa);
  test(0x0, bitShiftLeft, 0x2, 0xbd217d);
  test(0x0, bitShiftLeft, 0x2, 0xfedcba98);
  test(0x0, bitShiftLeft, 0x2, 0xfffffffe);
  test(0x0, bitShiftLeft, 0x2, 0xffffffff);
  test(0xa, bitShiftLeft, 0xa, 0x0);
  test(0x14, bitShiftLeft, 0xa, 0x1);
  test(0x28, bitShiftLeft, 0xa, 0x2);
  test(0x2800, bitShiftLeft, 0xa, 0xa);
  test(0x0, bitShiftLeft, 0xa, 0xbd217d);
  test(0x0, bitShiftLeft, 0xa, 0xfedcba98);
  test(0x0, bitShiftLeft, 0xa, 0xfffffffe);
  test(0x0, bitShiftLeft, 0xa, 0xffffffff);
  test(0xbd217d, bitShiftLeft, 0xbd217d, 0x0);
  test(0x17a42fa, bitShiftLeft, 0xbd217d, 0x1);
  test(0x2f485f4, bitShiftLeft, 0xbd217d, 0x2);
  test(0xf485f400, bitShiftLeft, 0xbd217d, 0xa);
  test(0x0, bitShiftLeft, 0xbd217d, 0xbd217d);
  test(0x0, bitShiftLeft, 0xbd217d, 0xfedcba98);
  test(0x0, bitShiftLeft, 0xbd217d, 0xfffffffe);
  test(0x0, bitShiftLeft, 0xbd217d, 0xffffffff);
  test(0xfedcba98, bitShiftLeft, 0xfedcba98, 0x0);
  test(0xfdb97530, bitShiftLeft, 0xfedcba98, 0x1);
  test(0xfb72ea60, bitShiftLeft, 0xfedcba98, 0x2);
  test(0x72ea6000, bitShiftLeft, 0xfedcba98, 0xa);
  test(0x0, bitShiftLeft, 0xfedcba98, 0xbd217d);
  test(0x0, bitShiftLeft, 0xfedcba98, 0xfedcba98);
  test(0x0, bitShiftLeft, 0xfedcba98, 0xfffffffe);
  test(0x0, bitShiftLeft, 0xfedcba98, 0xffffffff);
  test(0xfffffffe, bitShiftLeft, 0xfffffffe, 0x0);
  test(0xfffffffc, bitShiftLeft, 0xfffffffe, 0x1);
  test(0xfffffff8, bitShiftLeft, 0xfffffffe, 0x2);
  test(0xfffff800, bitShiftLeft, 0xfffffffe, 0xa);
  test(0x0, bitShiftLeft, 0xfffffffe, 0xbd217d);
  test(0x0, bitShiftLeft, 0xfffffffe, 0xfedcba98);
  test(0x0, bitShiftLeft, 0xfffffffe, 0xfffffffe);
  test(0x0, bitShiftLeft, 0xfffffffe, 0xffffffff);
  test(0xffffffff, bitShiftLeft, 0xffffffff, 0x0);
  test(0xfffffffe, bitShiftLeft, 0xffffffff, 0x1);
  test(0xfffffffc, bitShiftLeft, 0xffffffff, 0x2);
  test(0xfffffc00, bitShiftLeft, 0xffffffff, 0xa);
  test(0x0, bitShiftLeft, 0xffffffff, 0xbd217d);
  test(0x0, bitShiftLeft, 0xffffffff, 0xfedcba98);
  test(0x0, bitShiftLeft, 0xffffffff, 0xfffffffe);
  test(0x0, bitShiftLeft, 0xffffffff, 0xffffffff);

  test(0x0, bitShiftRight, 0x0, 0x0);
  test(0x0, bitShiftRight, 0x0, 0x1);
  test(0x0, bitShiftRight, 0x0, 0x2);
  test(0x0, bitShiftRight, 0x0, 0xa);
  test(0x0, bitShiftRight, 0x0, 0xbd217d);
  test(0x0, bitShiftRight, 0x0, 0xfedcba98);
  test(0x0, bitShiftRight, 0x0, 0xfffffffe);
  test(0x0, bitShiftRight, 0x0, 0xffffffff);
  test(0x1, bitShiftRight, 0x1, 0x0);
  test(0x0, bitShiftRight, 0x1, 0x1);
  test(0x0, bitShiftRight, 0x1, 0x2);
  test(0x0, bitShiftRight, 0x1, 0xa);
  test(0x0, bitShiftRight, 0x1, 0xbd217d);
  test(0x0, bitShiftRight, 0x1, 0xfedcba98);
  test(0x0, bitShiftRight, 0x1, 0xfffffffe);
  test(0x0, bitShiftRight, 0x1, 0xffffffff);
  test(0x2, bitShiftRight, 0x2, 0x0);
  test(0x1, bitShiftRight, 0x2, 0x1);
  test(0x0, bitShiftRight, 0x2, 0x2);
  test(0x0, bitShiftRight, 0x2, 0xa);
  test(0x0, bitShiftRight, 0x2, 0xbd217d);
  test(0x0, bitShiftRight, 0x2, 0xfedcba98);
  test(0x0, bitShiftRight, 0x2, 0xfffffffe);
  test(0x0, bitShiftRight, 0x2, 0xffffffff);
  test(0xa, bitShiftRight, 0xa, 0x0);
  test(0x5, bitShiftRight, 0xa, 0x1);
  test(0x2, bitShiftRight, 0xa, 0x2);
  test(0x0, bitShiftRight, 0xa, 0xa);
  test(0x0, bitShiftRight, 0xa, 0xbd217d);
  test(0x0, bitShiftRight, 0xa, 0xfedcba98);
  test(0x0, bitShiftRight, 0xa, 0xfffffffe);
  test(0x0, bitShiftRight, 0xa, 0xffffffff);
  test(0xbd217d, bitShiftRight, 0xbd217d, 0x0);
  test(0x5e90be, bitShiftRight, 0xbd217d, 0x1);
  test(0x2f485f, bitShiftRight, 0xbd217d, 0x2);
  test(0x2f48, bitShiftRight, 0xbd217d, 0xa);
  test(0x0, bitShiftRight, 0xbd217d, 0xbd217d);
  test(0x0, bitShiftRight, 0xbd217d, 0xfedcba98);
  test(0x0, bitShiftRight, 0xbd217d, 0xfffffffe);
  test(0x0, bitShiftRight, 0xbd217d, 0xffffffff);
  test(0xfedcba98, bitShiftRight, 0xfedcba98, 0x0);
  test(0x7f6e5d4c, bitShiftRight, 0xfedcba98, 0x1);
  test(0x3fb72ea6, bitShiftRight, 0xfedcba98, 0x2);
  test(0x3fb72e, bitShiftRight, 0xfedcba98, 0xa);
  test(0x0, bitShiftRight, 0xfedcba98, 0xbd217d);
  test(0x0, bitShiftRight, 0xfedcba98, 0xfedcba98);
  test(0x0, bitShiftRight, 0xfedcba98, 0xfffffffe);
  test(0x0, bitShiftRight, 0xfedcba98, 0xffffffff);
  test(0xfffffffe, bitShiftRight, 0xfffffffe, 0x0);
  test(0x7fffffff, bitShiftRight, 0xfffffffe, 0x1);
  test(0x3fffffff, bitShiftRight, 0xfffffffe, 0x2);
  test(0x3fffff, bitShiftRight, 0xfffffffe, 0xa);
  test(0x0, bitShiftRight, 0xfffffffe, 0xbd217d);
  test(0x0, bitShiftRight, 0xfffffffe, 0xfedcba98);
  test(0x0, bitShiftRight, 0xfffffffe, 0xfffffffe);
  test(0x0, bitShiftRight, 0xfffffffe, 0xffffffff);
  test(0xffffffff, bitShiftRight, 0xffffffff, 0x0);
  test(0x7fffffff, bitShiftRight, 0xffffffff, 0x1);
  test(0x3fffffff, bitShiftRight, 0xffffffff, 0x2);
  test(0x3fffff, bitShiftRight, 0xffffffff, 0xa);
  test(0x0, bitShiftRight, 0xffffffff, 0xbd217d);
  test(0x0, bitShiftRight, 0xffffffff, 0xfedcba98);
  test(0x0, bitShiftRight, 0xffffffff, 0xfffffffe);
  test(0x0, bitShiftRight, 0xffffffff, 0xffffffff);

  test(0x0, bitShiftRightLogical, 0x0, 0x0);
  test(0x0, bitShiftRightLogical, 0x0, 0x1);
  test(0x0, bitShiftRightLogical, 0x0, 0x2);
  test(0x0, bitShiftRightLogical, 0x0, 0xa);
  test(0x0, bitShiftRightLogical, 0x0, 0xbd217d);
  test(0x0, bitShiftRightLogical, 0x0, 0xfedcba98);
  test(0x0, bitShiftRightLogical, 0x0, 0xfffffffe);
  test(0x0, bitShiftRightLogical, 0x0, 0xffffffff);
  test(0x1, bitShiftRightLogical, 0x1, 0x0);
  test(0x0, bitShiftRightLogical, 0x1, 0x1);
  test(0x0, bitShiftRightLogical, 0x1, 0x2);
  test(0x0, bitShiftRightLogical, 0x1, 0xa);
  test(0x0, bitShiftRightLogical, 0x1, 0xbd217d);
  test(0x0, bitShiftRightLogical, 0x1, 0xfedcba98);
  test(0x0, bitShiftRightLogical, 0x1, 0xfffffffe);
  test(0x0, bitShiftRightLogical, 0x1, 0xffffffff);
  test(0x2, bitShiftRightLogical, 0x2, 0x0);
  test(0x1, bitShiftRightLogical, 0x2, 0x1);
  test(0x0, bitShiftRightLogical, 0x2, 0x2);
  test(0x0, bitShiftRightLogical, 0x2, 0xa);
  test(0x0, bitShiftRightLogical, 0x2, 0xbd217d);
  test(0x0, bitShiftRightLogical, 0x2, 0xfedcba98);
  test(0x0, bitShiftRightLogical, 0x2, 0xfffffffe);
  test(0x0, bitShiftRightLogical, 0x2, 0xffffffff);
  test(0xa, bitShiftRightLogical, 0xa, 0x0);
  test(0x5, bitShiftRightLogical, 0xa, 0x1);
  test(0x2, bitShiftRightLogical, 0xa, 0x2);
  test(0x0, bitShiftRightLogical, 0xa, 0xa);
  test(0x0, bitShiftRightLogical, 0xa, 0xbd217d);
  test(0x0, bitShiftRightLogical, 0xa, 0xfedcba98);
  test(0x0, bitShiftRightLogical, 0xa, 0xfffffffe);
  test(0x0, bitShiftRightLogical, 0xa, 0xffffffff);
  test(0xbd217d, bitShiftRightLogical, 0xbd217d, 0x0);
  test(0x5e90be, bitShiftRightLogical, 0xbd217d, 0x1);
  test(0x2f485f, bitShiftRightLogical, 0xbd217d, 0x2);
  test(0x2f48, bitShiftRightLogical, 0xbd217d, 0xa);
  test(0x0, bitShiftRightLogical, 0xbd217d, 0xbd217d);
  test(0x0, bitShiftRightLogical, 0xbd217d, 0xfedcba98);
  test(0x0, bitShiftRightLogical, 0xbd217d, 0xfffffffe);
  test(0x0, bitShiftRightLogical, 0xbd217d, 0xffffffff);
  test(0xfedcba98, bitShiftRightLogical, 0xfedcba98, 0x0);
  test(0x7f6e5d4c, bitShiftRightLogical, 0xfedcba98, 0x1);
  test(0x3fb72ea6, bitShiftRightLogical, 0xfedcba98, 0x2);
  test(0x3fb72e, bitShiftRightLogical, 0xfedcba98, 0xa);
  test(0x0, bitShiftRightLogical, 0xfedcba98, 0xbd217d);
  test(0x0, bitShiftRightLogical, 0xfedcba98, 0xfedcba98);
  test(0x0, bitShiftRightLogical, 0xfedcba98, 0xfffffffe);
  test(0x0, bitShiftRightLogical, 0xfedcba98, 0xffffffff);
  test(0xfffffffe, bitShiftRightLogical, 0xfffffffe, 0x0);
  test(0x7fffffff, bitShiftRightLogical, 0xfffffffe, 0x1);
  test(0x3fffffff, bitShiftRightLogical, 0xfffffffe, 0x2);
  test(0x3fffff, bitShiftRightLogical, 0xfffffffe, 0xa);
  test(0x0, bitShiftRightLogical, 0xfffffffe, 0xbd217d);
  test(0x0, bitShiftRightLogical, 0xfffffffe, 0xfedcba98);
  test(0x0, bitShiftRightLogical, 0xfffffffe, 0xfffffffe);
  test(0x0, bitShiftRightLogical, 0xfffffffe, 0xffffffff);
  test(0xffffffff, bitShiftRightLogical, 0xffffffff, 0x0);
  test(0x7fffffff, bitShiftRightLogical, 0xffffffff, 0x1);
  test(0x3fffffff, bitShiftRightLogical, 0xffffffff, 0x2);
  test(0x3fffff, bitShiftRightLogical, 0xffffffff, 0xa);
  test(0x0, bitShiftRightLogical, 0xffffffff, 0xbd217d);
  test(0x0, bitShiftRightLogical, 0xffffffff, 0xfedcba98);
  test(0x0, bitShiftRightLogical, 0xffffffff, 0xfffffffe);
  test(0x0, bitShiftRightLogical, 0xffffffff, 0xffffffff);

  testUnary(0xffffffff, bitInvert, 0x0);
  testUnary(0xfffffffe, bitInvert, 0x1);
  testUnary(0xfffffffd, bitInvert, 0x2);
  testUnary(0xfffffff5, bitInvert, 0xa);
  testUnary(0xff42de82, bitInvert, 0xbd217d);
  testUnary(0x1234567, bitInvert, 0xfedcba98);
  testUnary(0x1, bitInvert, 0xfffffffe);
  testUnary(0x0, bitInvert, 0xffffffff);
}
